<?php

/******************************************
 * File:			lib_history.php
 * Version:			1.0.0
 * Last modified:	25/10/2009
 * Last modifier:	Hugo Lavigne
 *****************************************/
 
Function add_history($uid, $type, $link='', $value='')
{
	$date = date('Y-m-d H:i:s');
	$connection = dbconnect();
	$hid = create_mysql_id("history_users", "hid", $connection);
	$req = dbquery("INSERT INTO history_users VALUES($hid, \"$uid\", \"$type\", \"$link\", \"$value\", \"$date\")", $connection);
	mysql_close($connection);
	return (0);
}

Function add_notification($dest, $uid, $type, $link='', $value='')
{
	$date = date('Y-m-d H:i:s');
	$connection = dbconnect();
	$nid = create_mysql_id("history_users_notes", "nid", $connection);
	$req = dbquery("INSERT INTO history_users_notes VALUES($nid, \"$dest\", \"$uid\", \"$type\", \"$link\", \"$value\", \"$date\", \"ko\")", $connection);
	mysql_close($connection);
	return (0);
}

Function delete_notes($dest, $nid)
{
	dbquery("DELETE FROM history_users_notes WHERE dest='$dest' AND nid='$nid'");
	return (0);
}

Function get_nb_notes()
{
	$req = dbquery("SELECT nid FROM history_users_notes WHERE dest=\"$_SESSION[uid]\" AND status=\"ko\"");
	if (@mysql_num_rows($req) > 0)
		return (mysql_num_rows($req));
	return (0);
}

?>